package com.xhwl.centiotdata.pojo.dto.passengerflow;

import com.alibaba.fastjson.JSONObject;
import com.xhwl.common.pojo.cent.device.DeviceProjSupplierCategory;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.extern.slf4j.Slf4j;

import java.util.List;
import java.util.Objects;

/**
 * @Author： zhouxudong
 * @Description：
 * @Date 2023/4/9 09:42
 */
@Data
@Slf4j
@EqualsAndHashCode
public class PassengerFlowIntegrationConfigDTO {

    private Integer projectId;

    private Integer productId;

    private String ipAndPort;

    private String loginName;

    private String password;

    private String token;

    private List<PassengerFlowRegionConfig> regionConfigs;

    private String ak;

    private String sk;


    public static PassengerFlowIntegrationConfigDTO toPassengerFlow(DeviceProjSupplierCategory supplierCategory) {
        PassengerFlowIntegrationConfigDTO dto = new PassengerFlowIntegrationConfigDTO();
        JSONObject properties = supplierCategory.getProperties();
        if (Objects.nonNull(properties)) {
            dto = properties.toJavaObject(PassengerFlowIntegrationConfigDTO.class);
        }
        dto.setProductId(supplierCategory.getProductId());
        dto.setProjectId(supplierCategory.getProjectId());
        return dto;
    }
}
